home *** CD-ROM | disk | FTP | other *** search
- package sub_arctic.demo_apps;
-
- import sub_arctic.lib.listbox;
- import sub_arctic.lib.manager;
- import sub_arctic.lib.interactor;
- import sub_arctic.input.event;
- import sub_arctic.input.callback_object;
-
- import java.util.Vector;
-
- /**
- * This is a subclass of listbox which we use to display our mail
- * headers in.
- */
- public class header_listbox extends listbox implements callback_object {
- /**
- * We need a handle to the applet.
- */
- mail_test applet;
- /**
- * This is the function that gets called when we double click
- * on a mail message.
- */
- public void handle_double_click() {
- create_message();
- }
- /**
- * Propagate the constructor ... we know that our listboxes are
- * going to use cosntraints for their sizes, so we just put 10,10
- * as the size and know it will get overrided later.
- * We pass the applet because we need to be able to see some
- * of its data structures for creating new messages.
- */
- public header_listbox(boolean single, mail_test a) {
- super(10,10,single,null);
- /* set the callback object to be this ... can't do this in the
- super() call as we can't reference this yet */
- set_callback_obj(this);
- /* set the draggability to true */
- set_allow_dragging(true);
- applet=a;
- }
- /**
- * This function sizes a new message for you.
- */
- public static void size_message(message_display display) {
- display.set_w(530);
- display.set_h(300);
- /* now if the text is actually smaller than this size, we should
- * use that size */
- if (display.text_height()<display.h()) {
- display.set_h(display.text_height()+12);
- }
- if (display.text_width()<display.w()) {
- display.set_w(display.text_width()+12);
- }
- }
- /**
- * This pops up a message when they double click on it.
- */
- public void create_message() {
- message msg=(message)focused();
- message_display display=new message_display(msg,applet);
-
- /* we know that the parent() of this object is the top_object
- * and the parent() of that is the applet
- */
- applet.playing_field().add_child(display);
- display.set_x(10);
- display.set_y(10);
- size_message(display);
- }
- /**
- * This is the function that gets called when the user initiates a
- * drag. We want to create a message icon which we can drag.
- */
- public void handle_drag(event evt) {
- message_icon mi;
- message msg[];
- Vector v;
- int i;
- /* make sure images are loaded... not really needed
- now but might be shortly */
- if (message_display.delete_icon==null) {
- message_display.load_icons(applet);
- }
- /* now build the icon and then set it to be the drag focus */
- /* remove the listbox from the focus of the simple drag*/
- manager.simple_drag_focus.remove_from_focus(this,evt);
- /* figure out how many objects are currently selected */
- v=selected_set();
- /* build an array of messages that is that size */
- msg=new message[v.size()];
- /* initialize the array of messages*/
- for (i=0; i<msg.length;++i) {
- msg[i]=(message)v.elementAt(i);
- }
- /* create a new icon */
- mi=new message_icon(msg,evt.global_x(),evt.global_y(),
- get_top_level(),applet,true /* from here */);
- /* make it the move-drag focus */
- manager.move_drag_focus.set_focus_to(mi,evt,null);
- }
- /**
- * This is what gets called in response to a callback.
- */
- public void callback(interactor from_obj,
- event evt,
- int callback_num,
- Object callback_info) {
-
- /* are we getting called back by our own object? */
- if (from_obj==this) {
- if (callback_num==listbox.DOUBLE_CLICK) {
- handle_double_click();
- }
- if (callback_num==listbox.DRAG) {
- handle_drag(evt);
- }
- return;
- }
- /* this is used so that the scrollbar callback works properly */
- super.callback(from_obj, evt, callback_num, callback_info);
- }
-
- }
-
- /*=========================== COPYRIGHT NOTICE ===========================
-
- This file is part of the subArctic user interface toolkit.
-
- Copyright (c) 1996 Scott Hudson and Ian Smith
- All rights reserved.
-
- The subArctic system is freely available for most uses under the terms
- and conditions described in
- http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html
- and appearing in full in the lib/interactor.java source file.
-
- The current release and additional information about this software can be
- found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
-
- ========================================================================*/
-